// UC1609C 192*64 LCM 的 AVR 驱动。
// 本驱动需要根据接线修改端口设置，设置在configure.h
// 源代码发布在  https://gitee.com/redpower/uc1609c_avr
// 木兰开放许可协议
//  

//晶振频率
#define F_CPU 3686400UL
//波特率
#define BAUD 115200

#include <avr/interrupt.h>
#include <avr/io.h>

#include <avr/pgmspace.h>
#include <util/delay.h>
#include <stdlib.h>
#include <string.h>
#include "lcd_uc1609c.h"

#include "configure.h"
#include "lcd_fonts.h"


//主函数

int main(void)
{

  DDRB = 1 << CS | 1 << CD | 1 << RST | 1 << SDA | 1 << SCK;
  PORTB = 0xFF;

  _delay_ms(500);

  lcd_init();

  lcd_set_dark();
  while (1)
  {
    lcd_invert_display(FALSE); //不反转色彩显示
                           
    lcd_set_dark();
	for(int i=1;i<9;i++)
	{
		for(int j=0;j<32;j++)
		{
			lcd_put_char_7x5(i,(j*6)+1,'0'+j);
		}
	}
    _delay_ms(1500);

    lcd_set_dark();
    lcd_put_chars_7x5(1, 1, "Hello world123456789012345678901234567890");
    lcd_put_chars_7x5(4, 1, "No Line4 Hello world123456789012345678901234567890");
    lcd_put_chars_7x5(7, 1, "No Line7 Hello world123456789012345678901234567890");
    _delay_ms(1500);

    lcd_set_dark();
    graphics_clear_buf();
    for (int i = 0; i < 64; i++)
      graphics_draw_pixel(i, 20, INVERSE);
    graphics_draw_circle(16, 16, 10, FOREGROUND);
    graphics_draw_circle_helper(20, 20, 10, 1, FOREGROUND);
    graphics_draw_line(0, 0, 64, 64, FOREGROUND);
    graphics_fill_circle(32, 32, 5, FOREGROUND);
    graphics_draw_char(20, 20, 'H', FOREGROUND, BACKGROUND, 2);
    graphics_update();
    _delay_ms(1500);

    
	lcd_set_dark();
	lcd_draw_bitmap_p(60, 25, 20, 20, smallImage);
	_delay_ms(1500);



	lcd_set_dark();
	lcd_draw_bitmap_p(0, 0, 192, 64, pic1);
	_delay_ms(1500);


    lcd_invert_display(TRUE);
	
	lcd_set_dark();
    lcd_put_chars_16x8(1,1,"Hello world12345678901234567890");
	lcd_put_chars_16x8(3,1,"No Line2 Hello world123456789012345678901234567890");
	lcd_rotate(0x06);
    _delay_ms(1500);



	lcd_fill_screen(0xFF);
	_delay_ms(1000);

	lcd_fill_screen(0x00);
	_delay_ms(1000);

	lcd_fill_screen(0xF0);
	_delay_ms(1000);


    lcd_set_dark();
	for(int i=0;i<4;i++)
	{
		for(int j=0;j<24;j++)
		{
			lcd_put_char_16x8((i*2)+1,(j*8)+1,'0'+j);
		}
	}
	lcd_rotate(0x02);  //不旋转
	_delay_ms(3000);


	lcd_set_dark();
	lcd_display_16x16(1,1,lei1); //在第1页，第1列显示单个自编生僻汉字"畾“
	_delay_ms(1500);

	lcd_set_dark();
	lcd_display_32x64(1,17,zi1); 
	_delay_ms(1500);

  }

  return 0;
}

